﻿namespace Vdc.Grid
{
    using System;

    internal class GridEncodingHelper
    {
        internal static string XMLCdataEncode(string text)
        {
            return XMLCdataEncode(text, false);
        }

        internal static string XMLCdataEncode(string text, bool encodeEmptySpaces)
        {
            string str = text.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;");
            if (encodeEmptySpaces)
            {
                str = str.Replace("  ", " &#160;");
            }
            return str;
        }
    }
}

